package com.yanqu.road.server.cmd.unionwar;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.unionwar.UnionWarActivityServerProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.unionwar.CrossUnionWarGuessMgr;
import com.yanqu.road.server.protocol.CrossProtocol;

import java.util.List;

@Cmd(code = CrossProtocol.C_CROSS_UNION_WAR_SYNC_GUESS_DATA, desc = "同步竞猜数据")
public class CrossUnionWarSyncGuessDataCmd extends CrossUnionCommand {
    private int activityId;
    private int stage;
    private List<String> guessList;
    private long userId;
    private PlayerProto.PlayerBaseTempMsg playerBaseInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        UnionWarActivityServerProto.SyncCrossGuessDataMsg msg = UnionWarActivityServerProto.SyncCrossGuessDataMsg.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        stage = msg.getStage();
        guessList = msg.getUnionUidList();
        playerBaseInfo = msg.getPlayerBaseInfo();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossUnionWarGuessMgr.changeUnionGuess(activityId, stage, serverId, userId, guessList, playerBaseInfo);
    }

    @Override
    public void sendData() {

    }
}
